/**
 * Created by ruby on 2/22/17.
 */

let eventproxy = require('eventproxy');

let ep = new eventproxy();

/**
 on/addListener，绑定事件监听器
 emit，触发事件
 once，绑定只执行一次的事件监听器
 removeListener，移除事件的监听器
 removeAllListeners，移除单个事件或者所有事件的监听器
 */

ep.all('one', 'two', 'three', function (one, two, three) {
  console.log(one, two, three);
});
ep.fail(function (error) {
  console.log(error);
});


setTimeout(function () {
  ep.emit('one', 'one');
  console.log('this is one');
}, 3000);

setTimeout(function () {
  ep.emit('two', 'two');
  console.log('this is two');
}, 1000);

setTimeout(function () {
  //ep.emit('three', 'three');
  ep.emit('error', 'err');
  console.log('this is three');
}, 2000);
